home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / util / gnu / cvs-1.11.1p1.lha / contrib / rcs2sccs.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2001-02-28  |  3.9 KB  |  142 lines

  1. #! /bin/sh
  2. #
  3. #
  4.  
  5. ############################################################
  6. # Error checking
  7. #
  8. if [ ! -d SCCS ] ; then
  9.     mkdir SCCS
  10. fi
  11.  
  12. logfile=/tmp/rcs2sccs_$$_log
  13. rm -f $logfile
  14. tmpfile=/tmp/rcs2sccs_$$_tmp
  15. rm -f $tmpfile
  16. emptyfile=/tmp/rcs2sccs_$$_empty
  17. echo -n "" > $emptyfile
  18. initialfile=/tmp/rcs2sccs_$$_init
  19. echo "Initial revision" > $initialfile
  20. sedfile=/tmp/rcs2sccs_$$_sed
  21. rm -f $sedfile
  22. revfile=/tmp/rcs2sccs_$$_rev
  23. rm -f $revfile
  24. commentfile=/tmp/rcs2sccs_$$_comment
  25. rm -f $commentfile
  26.  
  27. # create the sed script
  28. cat > $sedfile << EOF
  29. s,;Id;,%Z%%M% %I% %E%,g
  30. s,;SunId;,%Z%%M% %I% %E%,g
  31. s,;RCSfile;,%M%,g
  32. s,;Revision;,%I%,g
  33. s,;Date;,%E%,g
  34. s,;Id:.*;,%Z%%M% %I% %E%,g
  35. s,;SunId:.*;,%Z%%M% %I% %E%,g
  36. s,;RCSfile:.*;,%M%,g
  37. s,;Revision:.*;,%I%,g
  38. s,;Date:.*;,%E%,g
  39. EOF
  40. sed -e 's/;/\\$/g' $sedfile > $tmpfile
  41. cp $tmpfile $sedfile
  42. ############################################################
  43. # Loop over every RCS file in RCS dir
  44. #
  45. for vfile in *,v; do
  46.     # get rid of the ",v" at the end of the name
  47.     file=`echo $vfile | sed -e 's/,v$//'`
  48.  
  49.     # work on each rev of that file in ascending order
  50.     firsttime=1
  51.     rlog $file | grep "^revision [0-9][0-9]*\." | awk '{print $2}' | sed -e 's/\./ /g' | sort -n -u +0 +1 +2 +3 +4 +5 +6 +7 +8 | sed -e 's/ /./g' > $revfile
  52.     for rev in `cat $revfile`; do
  53.         if [ $? != 0 ]; then
  54.         echo ERROR - revision
  55.         exit
  56.     fi
  57.         # get file into current dir and get stats
  58.         date=`rlog -r$rev $file | grep "^date: " | awk '{print $2; exit}' | sed -e 's/^19//'`
  59.         time=`rlog -r$rev $file | grep "^date: " | awk '{print $3; exit}' | sed -e 's/;//'`
  60.         author=`rlog -r$rev $file | grep "^date: " | awk '{print $5; exit}' | sed -e 's/;//'`
  61.     date="$date $time"
  62.         echo ""
  63.     rlog -r$rev $file | sed -e '/^branches: /d' -e '1,/^date: /d' -e '/^===========/d' -e 's/$/\\/' | awk '{if ((total += length($0) + 1) < 510) print $0}' > $commentfile
  64.         echo "==> file $file, rev=$rev, date=$date, author=$author"
  65.     rm -f $file
  66.         co -r$rev $file >> $logfile  2>&1
  67.         if [ $? != 0 ]; then
  68.         echo ERROR - co
  69.         exit
  70.     fi
  71.         echo checked out of RCS
  72.  
  73.         # add SCCS keywords in place of RCS keywords
  74.         sed -f $sedfile $file > $tmpfile
  75.         if [ $? != 0 ]; then
  76.         echo ERROR - sed
  77.         exit
  78.     fi
  79.         echo performed keyword substitutions
  80.     rm -f $file
  81.         cp $tmpfile $file
  82.  
  83.         # check file into SCCS
  84.         if [ "$firsttime" = "1" ]; then
  85.             firsttime=0
  86.         echo about to do sccs admin
  87.             echo sccs admin -n -i$file $file < $commentfile
  88.             sccs admin -n -i$file $file < $commentfile >> $logfile 2>&1
  89.             if [ $? != 0 ]; then
  90.             echo ERROR - sccs admin
  91.             exit
  92.         fi
  93.             echo initial rev checked into SCCS
  94.         else
  95.         case $rev in
  96.         *.*.*.*)
  97.         brev=`echo $rev | sed -e 's/\.[0-9]*$//'`
  98.         sccs admin -fb $file 2>>$logfile
  99.         echo sccs get -e -p -r$brev $file
  100.         sccs get -e -p -r$brev $file >/dev/null 2>>$logfile
  101.         ;;
  102.         *)
  103.         echo sccs get -e -p $file
  104.         sccs get -e -p $file >/dev/null 2>> $logfile
  105.         ;;
  106.         esac
  107.         if [ $? != 0 ]; then
  108.             echo ERROR - sccs get
  109.             exit
  110.         fi
  111.         sccs delta $file < $commentfile >> $logfile 2>&1
  112.             if [ $? != 0 ]; then
  113.             echo ERROR - sccs delta -r$rev $file
  114.             exit
  115.         fi
  116.             echo checked into SCCS
  117.     fi
  118.     sed -e "s;^d D $rev ../../.. ..:..:.. [^ ][^ ]*;d D $rev $date $author;" SCCS/s.$file > $tmpfile
  119.     rm -f SCCS/s.$file
  120.     cp $tmpfile SCCS/s.$file
  121.     chmod 444 SCCS/s.$file
  122.     sccs admin -z $file
  123.         if [ $? != 0 ]; then
  124.         echo ERROR - sccs admin -z
  125.         exit
  126.     fi
  127.     done
  128.     rm -f $file
  129. done
  130.  
  131.  
  132. ############################################################
  133. # Clean up
  134. #
  135. echo cleaning up...
  136. rm -f $tmpfile $emptyfile $initialfile $sedfile $commentfile
  137. echo ===================================================
  138. echo "       Conversion Completed Successfully"
  139. echo ===================================================
  140.  
  141. rm -f *,v
  142.